import { PORT1 } from "@/api/config/servicePort";
import authMenuList from "@/assets/json/authMenuList.json";
import authButtonList from "@/assets/json/authButtonList.json";
import { useUserStore } from "@/stores/modules/user"; // 导入用户状态管理store
import http from "@/api";
/**
 * @name 登录模块
 */
// 用户登录
export const loginApi = params => {
  return http.post(PORT1 + `/login`, params, { loading: false }); // 正常 post json 请求  ==>  application/json
};

// 获取菜单列表
export const getAuthMenuListApi = () => {
  const userStore = useUserStore(); // 获取用户状态管理store实例

  return http.get(PORT1 + `/routersnav`, { "userdepartment": userStore.userdepartment }, { loading: false });
  // 如果想让菜单变为本地数据，注释上一行代码，并引入本地 authMenuList.json 数据
};

// 获取按钮权限
export const getAuthButtonListApi = () => {
  // return http.get(PORT1 + `/auth/buttons`, {}, { loading: false });
  // 如果想让按钮权限变为本地数据，注释上一行代码，并引入本地 authButtonList.json 数据
  return authButtonList;
};

// 用户退出登录
export const logoutApi = () => {
  return http.post(PORT1 + `/login`);
};
